<?php require_once('function/includes.php'); Session::start(); ?>
<!DOCTYPE html>
<html>
<head>
	<title>Health Tracker - Sign Up</title>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
	<link rel="stylesheet" type="text/css" href="">
</head>
<body>
	<div id="wrap">
		<header>
		</header>
		<div id="main">
			<div id="menu">
			</div>
			<div id="content">

				<?php if (isset($_GET['role']) && ($_GET['role'] === 'patient' || $_GET['role'] === 'doctor')) { ?>
					<form action="function/signup_function.php" method="POST">
					<label for="username">Username:</label> <input type="text" id="username" name="username"/> <br />
					<label for="password">Password:</label> <input type="password" id="password" name="password"/> <br /> 
					<label for="email">Email:</label> <input type="email" id="email" name="email"/> <br />
					
					<label for="firstname">First name:</label> <input type="text" id="firstname" name="firstname"/>  <br />
					<label for="lastname">Last name:</label> <input type="text" id="lastname" name="lastname"/>  <br />
					<label for="gender">Gender:</label>
					<select id="gender" name="gender">
						<option value="male">Male</option>
						<option value="female">Female</option>
					</select> <br />
					<label for="address">Address:</label> <input type="text" id="address" name="address"/> <br />
					<label for="contact">Contact:</label> <input type="text" id="contact" name="contact"/> <br />
					<label for="day">Day:</label>
					<select id="day" name="day">
					<?php for ($i=1; $i<=31; $i++) {echo '<option value="'.$i.'">'.str_pad($i, 2, "0", STR_PAD_LEFT).'</option>';}?>
					</select>
					<label for="month">Month:</label>
					<select id="month" name="month">
					<?php for ($i=1; $i<=12; $i++) {echo '<option value="'.$i.'">'.str_pad($i, 2, "0", STR_PAD_LEFT).'</option>';}?>
					</select>	
					<label for="year">Year:</label>
					<select id="year" name="year">
					<?php for ($i=2012; $i>=1900; $i--) {echo '<option value="'.$i.'">'.str_pad($i, 2, "0", STR_PAD_LEFT).'</option>';}?>
					</select> <br /> <br />


					<?php if ($_GET['role'] === 'patient') { ?>
						<input type="hidden" id="role" name="role" value="patient"/> 
						<label for="bloodtype">Blood Type:</label> <input type="text" id="bloodtype" name="bloodtype" value="NA" /> <br /> 
						<label for="allergy">Allergy:</label> <input type="text" id="allergy" name="allergy" /> <br />
						
					<?php } else if ($_GET['role'] === 'doctor') { ?>
						<input type="hidden" id="role" name="role" value="doctor"/> 
						<label for="regno">Registration no:</label> <input type="text" id="regno" name="regno"/>  <br />
						<label for="hospital">Hospital</label> <br />
						<?php 
						$hospital_list = Hospital::getHospitalList();
							if ($hospital_list !== null) {
						?>
						<select id="hospital" name="hospital">
						<?php 

								foreach ($hospital_list as $hospital) {
									echo '<option value="' . $hospital['hospital_id'] . '">' . $hospital['hospital_name'] . '</option>';
								}
						?>
						<option value="0">Others</option>
						</select> <br />
						<?php } ?>
						<label for="hospitalName">Name:</label> 
						<input type="text" id="hospitalName" name="hospitalName" /> <br />
						<label for="hospitalAddress">Address:</label> 
						<input type="text" id="hospitalAddress" name="hospitalAddress" /> <br />
						<label for="hospitalContact">Contact:</label> 
						<input type="text" id="hospitalContact" name="hospitalContact" /> <br /> <br />
						<label for="speciality">Speciality</label> <input type="text" id="speciality" name="speciality"/>  <br />
					<?php } ?>
					<input type="submit" name="submit" value="Submit" />
					<br />
					</form>
					<a href="signup.php">Back</a>
				<?php } else { ?>
					<a href="signup.php?role=patient">Create patient</a> |
					<a href="signup.php?role=doctor">Create doctor</a>
				<?php } ?>
			
			</div>
		</div>
		<footer>
			<div id="footer">
				
			</div>
		</footer>
	</div>
</body>